﻿using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using Lhn.Ds.Core.Service;

namespace Lhn.Ds.Core.Controll
{
    public class CardInfoModel : INotifyPropertyChanged
    {
        //卡的唯一id
        private string _code;
        /// <summary>
        /// 卡的唯一ID，卡自带的
        /// </summary>
        public string Code
        {
            get => _code;
            set
            {
                if (_code == value) return;
                _code = value;
                OnPropertyChanged();
            }
        }

        private CarTypeEnum _type;
        /// <summary>
        /// 卡类型
        /// </summary>
        public CarTypeEnum Type
        {
            get => _type;
            set
            {
                if (_type == value) return;
                _type = value;
                OnPropertyChanged();
            }
        }

        private string _numer;
        /// <summary>
        /// 卡编号，印在卡片上的
        /// </summary>
        public string Numer
        {
            get => _numer;
            set
            {
                if (_numer == value) return;
                _numer = value;
                OnPropertyChanged();
            }
        }


        private int _balance;
        /// <summary>
        /// 当前卡余额
        /// </summary>
        public int Balance
        {
            get => _balance;
            set
            {
                if (_balance == value) return;
                _balance = value;
                OnPropertyChanged();
            }
        }

        private uint _total;
        /// <summary>
        /// 消费累计
        /// </summary>
        public uint Total
        {
            get => _total;
            set
            {
                if (_total == value) return;
                _total = value;
                OnPropertyChanged();
            }
        }

        private int _count;
        /// <summary>
        /// 消费次数累计
        /// </summary>
        public int Count
        {
            get => _count;
            set
            {
                if (_count == value) return;
                _count = value;
                OnPropertyChanged();
            }
        }

        private int _flags;
        /// <summary>
        /// 断网次数
        /// </summary>
        public int Flags
        {
            get => _flags;
            set
            {
                if (_flags == value) return;
                _flags = value;
                OnPropertyChanged();
            }
        }
        /// <summary>
        /// 最后同步时间
        /// </summary>
        private DateTime _lastSyncTime;

        public DateTime LastSyncTime
        {
            get => _lastSyncTime;
            set
            {
                if (_lastSyncTime == value) return;
                _lastSyncTime = value;
                OnPropertyChanged();
            }
        }

        private string _phone;

        public string Phone
        {
            get => _phone;
            set
            {
                if (_phone == value) return;
                _phone = value;
                OnPropertyChanged();
            }
        }

        private long _id;
        /// <summary>
        /// 卡在服务器端存放的id，新卡则为0
        /// </summary>
        public long Id
        {
            get => _id;
            set
            {
                if (_id == value) return;
                _id = value;
                OnPropertyChanged();
            }
        }
        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        private CardState _cardState=CardState.Normal;
        /// <summary>
        /// 卡的状态
        /// </summary>
        public CardState CardState
        {
            get => _cardState;
            set
            {
                if (_cardState == value) return;
                _cardState = value;
                OnPropertyChanged();
            }
        }

        

    }

    public enum CarTypeEnum
    {
        //个人
        UseCard
    }

    public enum CardState
    {
        //空白卡
        Bank,

        //正常
        Normal,

        //绑定
        Binding,

        //挂失
        Loss
    }
}